package com.ruoyi.course.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.course.mapper.CourseCategoriesMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruoyi.course.domain.CourseCategories;
import com.ruoyi.course.service.ICourseCategoriesService;

/**
 * 课程分类Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-12
 */
@Service("CourseCategoriesService")
public class CourseCategoriesServiceImpl implements ICourseCategoriesService 
{
    @Autowired
    private CourseCategoriesMapper courseCategoriesMapper;
    /**
     * 查询课程分类
     * 
     * @param id 课程分类主键
     * @return 课程分类
     */
    @Override
    public CourseCategories selectCourseCategoriesById(String id)
    {
        return courseCategoriesMapper.selectCourseCategoriesById(id);
    }

    /**
     * 查询课程分类列表
     * 
     * @param courseCategories 课程分类
     * @return 课程分类
     */
    @Override
    public List<CourseCategories> selectCourseCategoriesList(CourseCategories courseCategories)
    {
        return courseCategoriesMapper.selectCourseCategoriesList(courseCategories);
    }

    /**
     * 新增课程分类
     * 
     * @param courseCategories 课程分类
     * @return 结果
     */
    @Override
    public int insertCourseCategories(CourseCategories courseCategories)
    {
        courseCategories.setCreateTime(DateUtils.getNowDate());
        return courseCategoriesMapper.insertCourseCategories(courseCategories);
    }

    /**
     * 修改课程分类
     * 
     * @param courseCategories 课程分类
     * @return 结果
     */
    @Override
    public int updateCourseCategories(CourseCategories courseCategories)
    {
        return courseCategoriesMapper.updateCourseCategories(courseCategories);
    }

    /**
     * 批量删除课程分类
     * 
     * @param ids 需要删除的课程分类主键
     * @return 结果
     */
    @Override
    public int deleteCourseCategoriesByIds(Integer[] ids) {
        for (Integer id : ids) {
           if (courseCategoriesMapper.selectDetail(id)!=null){
               return -200;
           }
        }
        return courseCategoriesMapper.deleteCourseCategoriesByIds(ids);
    }

    /**
     * 删除课程分类信息
     * 
     * @param id 课程分类主键
     * @return 结果
     */
    @Override
    public int deleteCourseCategoriesById(Integer id)
    {
        if (courseCategoriesMapper.selectDetail(id) !=null){
            return -200;
        }else{
        return courseCategoriesMapper.deleteCourseCategoriesById(id);}
    }

    @Override
    public CourseCategories selectDetail(Integer id) {
        return courseCategoriesMapper.selectDetail(id);
    }
}
